package com.heima.wemedia;

import com.heima.file.service.FileStorageService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;

import java.io.File;
import java.io.FileInputStream;

@SpringBootTest
public class OssDemo {

    @Autowired
    FileStorageService fileStorageService;
    @Value("${file.oss.web-site}")
    String webSite;

    @Value("${file.oss.prefix}")
    String prefix;

    @Test
    public void testFileUpload() throws Exception {
//上传文件素材
        FileInputStream inputStream = new FileInputStream(new File("E:\\Tercent\\360SoftMgrSafeRun\\视频\\c1.jpg"));

        String wemedia = fileStorageService.store("entriment", "aaa1.jpg", inputStream);
//        System.out.println(webSite+wemedia);
    }
    @Test
    public void testFiledelete() throws Exception {

        // 删除文件
        fileStorageService.delete("material/2022/7/20220704/aaa1.jpg");
    }
}
